﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using EZCRS.HCMS.Entity;
using EZCRS.HCMS.SqlClient;


namespace EZCRS.HCMS.Bll
{
    public class Bllhfg_module_help
    {
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="page">当前页数</param>
        /// <param name="pagecount">总页数</param>
        /// <param name="swhere">查询条件</param>
        /// <returns></returns>
        public List<hfg_module_help> getallbypage(int page, out int pagecount, string swhere)
        {
            //查询条件
            string strwhere = swhere;
            if (swhere == "")
                swhere = " 1=1 ";

            return new sql_hfg_module_help().getallbypage(page, strwhere, out pagecount);
        }

        /// <summary>
        /// 获得所有符合条件的记录
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public List<hfg_module_help> getitem(string search)
        {
            string sqlwhere = search;
            if (sqlwhere == "")
                sqlwhere = " 1=1 ";
            return new sql_hfg_module_help().getall(sqlwhere);
        }

        /// <summary>
        /// 获得所有符合条件的记录
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public List<hfg_module_help> getitem(string search,string orderstr)
        {
            string sqlwhere = search;
            if (sqlwhere == "")
                sqlwhere = " 1=1 ";
            return new sql_hfg_module_help().getall(sqlwhere,orderstr);
        }


        /// <summary>
        /// 获得一条记录
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public hfg_module_help getitem(int id)
        {
            return new sql_hfg_module_help().getitem(id);
        }

        #region 删除
        /// <summary>
        /// 删除一条记录
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool deleteitem(int id)
        {
            return new sql_hfg_module_help().deleteitem(id);
        }

        /// <summary>
        /// 删除一系列数据
        /// </summary>
        /// <param name="idlist"></param>
        /// <returns></returns>
        public bool deleteitem(string idlist)
        {
            return new sql_hfg_module_help().deleteitem(idlist);
        }
        #endregion

        /// <summary>
        /// 添加或修改
        /// </summary>
        /// <param name="_log"></param>
        /// <returns></returns>
        public bool insertorupdateitem(hfg_module_help _log)
        {
            return new sql_hfg_module_help().insertorupdate(_log);
        }



        public string getjson(int CCmoduleid)
        {
            List<hfg_module_help> helplist = getitem(" mid="+CCmoduleid.ToString()+" ", " rank ");
            if (helplist == null || helplist.Count==0)
                return "";
            string str = "[";

            int i = 0;
            foreach (hfg_module_help help in helplist)
            {
                if (i > 0)
                    str += ",";
                str += "['"+help.comment.Replace("\r\n","<br />")+"']";
                i++;
            }
            str += "]";

            return str;
        }
    }
}
